﻿using System.Drawing;
using System.ComponentModel;

namespace HiStaff.Control
{
    [ToolboxBitmap(typeof(System.Windows.Forms.DataGridView))]
    public class HiGrid : Janus.Windows.GridEX.GridEX
    {
        private bool _mainGrid = true;
        [DefaultValue(true)]
        public bool MainGrid { get { return _mainGrid; } set { _mainGrid = value; } }
        [DefaultValue("Automatic")]
        public Janus.Windows.GridEX.FilterMode FilterMode
        {
            get { return base.FilterMode; }
            set { base.FilterMode = value; }
        }
        public HiGrid()
        {
            this.VisualStyle = Janus.Windows.GridEX.VisualStyle.Office2010;
            this.AlternatingColors = true;
            this.FilterRowButtonStyle = Janus.Windows.GridEX.FilterRowButtonStyle.ConditionOperatorDropDown;
            this.FilterRowUpdateMode = Janus.Windows.GridEX.FilterRowUpdateMode.WhenValueChanges;
            this.GridLines = Janus.Windows.GridEX.GridLines.Default;
            this.HideSelection = Janus.Windows.GridEX.HideSelection.Highlight;
            this.RecordNavigator = true;
            this.TotalRowPosition = Janus.Windows.GridEX.TotalRowPosition.BottomFixed;
            this.UpdateMode = Janus.Windows.GridEX.UpdateMode.CellUpdate;
            this.HeaderFormatStyle.LineAlignment = Janus.Windows.GridEX.TextAlignment.Center;
            this.HeaderFormatStyle.TextAlignment = Janus.Windows.GridEX.TextAlignment.Center;
            this.DynamicFiltering = true;
            this.UpdateOnLeave = true;
            this.NewRowFormatStyle.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
            this.GroupByBoxVisible = false;
        }
        protected override void OnCreateControl()
        {
            try
            {
                base.OnCreateControl();
                if (this.RootTable != null)
                {
                    foreach (Janus.Windows.GridEX.GridEXColumn col in this.RootTable.Columns)
                    {
                        col.HeaderToolTip = col.Caption.ToUpper();
                        col.Caption = col.Caption.ToUpper();
                    }
                }
            }
            catch
            {
                return;
            }
        }
    }
}
